<?php
header("Content-Type: text/html; charset=utf-8");
require_once("Base/db.php");

//$username	= $_POST['username'];
//$passwd		= $_POST['passwd'];

$username	= $_GET['username'];
$passwd		= $_GET['passwd'];

//$sql = "SELECT count(*) as count FROM power WHERE `user_name`='{$username}' AND `passwd`=md5('{$passwd}')";
$sql = "SELECT epl.first_name, epl.last_name, pw.power, post.post_name, com.company_name 
	FROM power pw INNER JOIN (employee epl , post , company com) 
	ON (epl.staff_id=pw.staff_id AND com.company_id=epl.in_company AND pw.post=post.post_id)";

$r = gQuery($sql);
//print_r($r);

if($r[0]>0){
	$re['status']	= 1;
	$re['msg']	= "success";
	$re['username']	= $username;
	$re['truename']	= $r[0]->first_name . $r[0]->last_name;
	$re['post']	= $r[0]->post_name;
	$re['power']	= $r[0]->power;
	$re['company_name']	= $r[0]->company_name;
}else{
	$re['status']	= 0;
	$re['msg']	= "fail";
}

echo json_encode($re);
?>
